﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoMapper;
using DomainModel.Entities;
using RemoteFacade.Models;

namespace RemoteFacade.Adapters
{
    public class UserAdapter : IUserAdapter
    {
        public UserAdapter()
        {
            Mapper.CreateMap<User, UserModel>();
            Mapper.CreateMap<UserModel, User>()
                .ForMember(x => x.MyUndeliveredMessages, y => y.Ignore())
                .ForMember(x => x.UndeliveredMessagesToMe, y => y.Ignore());
            //TODO: jakaś obsługa tych ignorowanych właściwości?
        }

        public UserModel MapToModel(User entity)
        {
            var model = Mapper.Map<UserModel>(entity);
            return model;
        }

        public User MapToEntity(UserModel model)
        {
            var entity = Mapper.Map<User>(model);
            return entity;
        }
    }
}
